Trees | Indices | Toggle frames |
---|
Visible text insertion marker for pyglet.text.layout.IncrementalTextLayout.
The caret is drawn as a single vertical bar at the document position on a text layout object. If mark is not None, it gives the unmoving end of the current text selection. The visible text selection on the layout is updated along with mark and position.
By default the layout's graphics batch is used, so the caret does not need to be drawn explicitly. Even if a different graphics batch is supplied, the caret will be correctly positioned and clipped within the layout.
Updates to the document (and so the layout) are automatically propagated to the caret.
The caret object can be pushed onto a window event handler stack with
Window.push_handlers
. The caret will respond correctly to keyboard,
text, mouse and activation events, including double- and triple-clicks.
If the text layout is being used alongside other graphical widgets, a
GUI toolkit will be needed to delegate keyboard and mouse events to the
appropriate widget. pyglet does not provide such a toolkit at this stage.
__init__(self,
layout,
batch=None,
color=( 0, 0, 0) )
Create a caret for a layout.
|
|
delete(self)
Remove the caret from its batch.
|
|
object |
get_style(self,
attribute)
Get the document's named style at the caret's current position.
|
set_style(self,
attributes)
Set the document style at the caret's current position.
|
|
move_to_point(self,
x,
y)
Move the caret close to the given window coordinate.
|
|
select_to_point(self,
x,
y)
Move the caret close to the given window coordinate while
maintaining the mark.
|
|
select_word(self,
x,
y)
Select the word at the given window coordinate.
|
|
select_paragraph(self,
x,
y)
Select the paragraph at the given window coordinate.
|
|
on_layout_update(self) | |
on_text(self,
text)
Handler for the pyglet.window.Window.on_text event.
|
|
on_text_motion(self,
motion,
select=False)
Handler for the pyglet.window.Window.on_text_motion event.
|
|
on_text_motion_select(self,
motion)
Handler for the pyglet.window.Window.on_text_motion_select event.
|
|
on_mouse_scroll(self,
x,
y,
scroll_x,
scroll_y)
Handler for the pyglet.window.Window.on_mouse_scroll event.
|
|
on_mouse_press(self,
x,
y,
button,
modifiers)
Handler for the pyglet.window.Window.on_mouse_press event.
|
|
on_mouse_drag(self,
x,
y,
dx,
dy,
buttons,
modifiers)
Handler for the pyglet.window.Window.on_mouse_drag event.
|
|
on_activate(self)
Handler for the pyglet.window.Window.on_activate event.
|
|
on_deactivate(self)
Handler for the pyglet.window.Window.on_deactivate event.
|
bool |
visible
Caret visibility.
|
(int, int, int) |
color
Caret color.
|
int |
position
Position of caret within document.
|
int |
mark
Position of immovable end of text selection within
document.
|
int |
line
Index of line containing the caret's position.
|
PERIOD = 0.5
|
|
SCROLL_INCREMENT = 16
|
(
0,
0,
0)
)
Create a caret for a layout.
By default the layout's batch is used, so the caret does not need to be drawn explicitly.
Remove the caret from its batch.
Also disconnects the caret from further layout events.
Get the document's named style at the caret's current position.
If there is a text selection and the style varies over the selection, pyglet.text.document.STYLE_INDETERMINATE is returned.
Set the document style at the caret's current position.
If there is a text selection the style is modified immediately. Otherwise, the next text that is entered before the position is modified will take on the given style.
Move the caret close to the given window coordinate.
The mark will be reset to None.
Handler for the pyglet.window.Window.on_text event.
Caret keyboard handlers assume the layout always has keyboard focus. GUI toolkits should filter keyboard and text events by widget focus before invoking this handler.
Handler for the pyglet.window.Window.on_text_motion event.
Caret keyboard handlers assume the layout always has keyboard focus. GUI toolkits should filter keyboard and text events by widget focus before invoking this handler.
Handler for the pyglet.window.Window.on_text_motion_select event.
Caret keyboard handlers assume the layout always has keyboard focus. GUI toolkits should filter keyboard and text events by widget focus before invoking this handler.
Handler for the pyglet.window.Window.on_mouse_scroll event.
Mouse handlers do not check the bounds of the coordinates: GUI toolkits should filter events that do not intersect the layout before invoking this handler.
The layout viewport is scrolled by SCROLL_INCREMENT pixels per "click".
Handler for the pyglet.window.Window.on_mouse_press event.
Mouse handlers do not check the bounds of the coordinates: GUI toolkits should filter events that do not intersect the layout before invoking this handler.
This handler keeps track of the number of mouse presses within a short span of time and uses this to reconstruct double- and triple-click events for selecting words and paragraphs. This technique is not suitable when a GUI toolkit is in use, as the active widget must also be tracked. Do not use this mouse handler if a GUI toolkit is being used.
Handler for the pyglet.window.Window.on_mouse_drag event.
Mouse handlers do not check the bounds of the coordinates: GUI toolkits should filter events that do not intersect the layout before invoking this handler.
Handler for the pyglet.window.Window.on_activate event.
The caret is hidden when the window is not active.
Handler for the pyglet.window.Window.on_deactivate event.
The caret is hidden when the window is not active.
Caret visibility.
The caret may be hidden despite this property due to the periodic blinking or by on_deactivate if the event handler is attached to a window.
Caret color.
The default caret color is [0, 0, 0] (black). Each RGB color component is in the range 0 to 255.
Position of immovable end of text selection within document.
An interactive text selection is determined by its immovable end (the caret's position when a mouse drag begins) and the caret's position, which moves interactively by mouse and keyboard input.
This property is None when there is no selection.
Index of line containing the caret's position.
When set, position is modified to place the caret on requested line while maintaining the closest possible X offset.
Trees | Indices | Toggle frames |
---|
Generated by Epydoc 3.0beta1 on Thu Dec 31 17:58:19 2009 | http://epydoc.sourceforge.net |